package com.netdisk.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.netdisk.dao.impl.CapacityDao;
import com.netdisk.entity.Capacity;
import com.netdisk.entity.Log;
import com.netdisk.service.Service;

/**
 * 磁盘容量Service类
 * 事物支持
 * @author chenlong
 *2013-4-13
 */
@Component("capacityService")
public class CapacityService extends Service<Capacity>{
	
	private CapacityDao capacityDao;
	
	public CapacityDao getCapacityDao() {
		return capacityDao;
	}
	
	@Resource(name="capacityDao")
	public void setCapacityDao(CapacityDao capacityDao) {
		this.capacityDao = capacityDao;
	}

	@Override
	public void save(Capacity obj, Log log) {
		capacityDao.save(obj);
		logDao.save(log);
	}

	@Override
	public void update(Capacity obj, Log log) {
		capacityDao.update(obj);
		logDao.save(log);
	}

	@Override
	public void delete(Capacity obj, Log log) {
		capacityDao.delete(obj);
		logDao.save(log);
	}

	@Override
	public List<Capacity> findAll() {
		return capacityDao.findAll();
	}

	@Override
	public Capacity findById(String id) {
		return capacityDao.findById(id);
	}

	@Override
	public List<Capacity> findByTop(int from, int max) {
		return capacityDao.findByTop(from, max);
	}
	
	public Capacity findByOwnerId(String ownerId){
		return capacityDao.findByOwnerId(ownerId);
	}
	
	public Capacity findByCompanyId(String companyId) {
		return capacityDao.findByCompanyId(companyId);
	}
	
	public Long countCompanyCapcityUsed(String companyId){
		return capacityDao.countCompanyCapcityUsed(companyId);
	}
	
}
